package com.htgd.gardenexpo.service.impl;

import com.htgd.gardenexpo.entity.GeConAnnouncementAccess;
import com.htgd.gardenexpo.dao.GeConAnnouncementAccessDao;
import com.htgd.gardenexpo.service.GeConAnnouncementAccessService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (GeConAnnouncementAccess)表服务实现类
 *
 * @author makejava
 * @since 2022-02-19 15:24:15
 */
@Service("geConAnnouncementAccessService")
public class GeConAnnouncementAccessServiceImpl implements GeConAnnouncementAccessService {
    @Resource
    private GeConAnnouncementAccessDao geConAnnouncementAccessDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public GeConAnnouncementAccess queryById(Integer id) {
        return this.geConAnnouncementAccessDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GeConAnnouncementAccess> queryAllByLimit(int offset, int limit) {
        return this.geConAnnouncementAccessDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param geConAnnouncementAccess 实例对象
     * @return 实例对象
     */
    @Override
    public GeConAnnouncementAccess insert(GeConAnnouncementAccess geConAnnouncementAccess) {
        this.geConAnnouncementAccessDao.insert(geConAnnouncementAccess);
        return geConAnnouncementAccess;
    }

    /**
     * 修改数据
     *
     * @param geConAnnouncementAccess 实例对象
     * @return 实例对象
     */
    @Override
    public GeConAnnouncementAccess update(GeConAnnouncementAccess geConAnnouncementAccess) {
        this.geConAnnouncementAccessDao.update(geConAnnouncementAccess);
        return this.queryById(geConAnnouncementAccess.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.geConAnnouncementAccessDao.deleteById(id) > 0;
    }
}
